package com.ruoyi.system.utils;

import java.util.Random;

public class GenerateCodeUtil {

    public static String generateRandomCode(int length){
        String characters = "ABCDEFGHIJKLMNOPQRSTUVNXYZabcdefghijklmnopqrstuvwxyz0123456789";
        StringBuilder sb =new StringBuilder();
        Random random =new Random();
        for(int i=0;i< length; i++) {
            int index = random.nextInt(characters.length());
            sb.append(characters.charAt(index));
        }
        return sb.toString();
    }
    public static String generateRandomString() {
        Random random = new Random();
        StringBuilder sb = new StringBuilder(8);
        for (int i = 0; i < 8; i++) {
            sb.append(random.nextInt(10));
        }
        return sb.toString();
    }
}
